from time import sleep

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

from ConfigFile.Varconfig import chromePath, testdata_path
from Modules.LoginMoudles import LoginAction
from Until.ExcelOprate import ExcelOprate
import unittest


# class test_Login:
#
#     try:
#         # chromeDriver_path = 'E:\Python\chromedriver.exe'
#         # options = Options()
#         # options.add_argument('--start-maximized')
#         # wd = webdriver.Chrome(executable_path=chromePath, options=options)
#         # wd.get('http://www.cherryzqr.top/fsmarket/index.php')
#         #
#         # Loginaction = LoginAction()
#         # Loginaction.login(wd,'cherry1','123456')
#
#         excel = ExcelOprate()
#         excel.load_workbook(testdata_path)
#         excel.get_sheet_by_name('Sheet1')
#         #获取行数 以遍历每一行数据
#         row_nums = excel.get_rows_nums()
#         #获取第一行标题为组装字典做准备
#         row_1_nums = excel.get_row_values(1)
#
#         for i in range(2,row_nums+1):
#             row_values = excel.get_row_values(i)
#             # print(row_values)
#             # 将每行数据和标题组装成字典
#             values = dict(zip(row_1_nums,row_values))
#             # print(values)
#             if values['is_excute'].lower() == 'y':
#                 username = values['username']
#                 password = values['password']
#                 options = Options()
#                 options.add_argument('--start-maximized')
#                 wd = webdriver.Chrome(executable_path=chromePath, options=options)
#                 wd.get('http://www.cherryzqr.top/fsmarket/index.php')
#
#                 Loginaction = LoginAction()
#                 Loginaction.login(wd,username,password)
#                 sleep(2)
#                 wd.quit()
#
#     except Exception as e:
#         raise e

class Login_Test(unittest.TestCase):

    # def setUp(self):
    #     print('='*10 + 'setup' + '='*10)
    #     option = Options()
    #     option.add_argument('--start-maximized')
    #     self.wd = webdriver.Chrome(chromePath,options=option)
    #     self.wd.get('http://www.cherryzqr.top/fsmarket/index.php')
    #
    # def tearDown(self):
    #     print('=' * 10 + 'tearDown' + '=' * 10)
    #     sleep(3)
    #     self.wd.quit()

    # 解决每个用例都调用setup和tearDown
    @classmethod
    def setUpClass(cls):
        print('='*10 + 'setup' + '='*10)
        # option = Options()
        # option.add_argument('--start-maximized')
        # cls.wd = webdriver.Chrome(chromePath,options=option)
        # cls.wd.get('http://www.cherryzqr.top/fsmarket/index.php')

    @classmethod
    def tearDown(cls):
        print('=' * 10 + 'tearDown' + '=' * 10)
        # sleep(3)
        # cls.wd.quit()


    # def test_01(self):
    #     print('test_01')
    #     loginAction = LoginAction()
    #     loginAction.login(self.wd,'cherry1','123456')

    def test_02(self):
        print('test_02')
        self.assertEqual(1,1)

    def test_03(self):
        print('test_03')
        self.assertEqual(2,2)

    def test_04(self):
        print('test_03')
        self.assertEqual(1, 2)

if __name__ == '__main__':
    # test_Login()
    unittest.main()
